<template>
    <div>
            <a-steps :current="current" style="position:relative;top:-50px">
      <!-- <a-step v-for="item in steps" :key="item.title" :title="item.title" /> -->
      <a-step title="邮箱验证"></a-step>
      <a-step title="密码修改" style="position:relative;left:-170px"></a-step>
      <a-step title="修改成功" style="position:relative;left:-150px"></a-step>
    </a-steps>
        <a-input-password placeholder="输入新密码" size="large" style="width:500px" v-model="password"/>
        <br>
        <br>
        <a-input-password placeholder="确认新密码" size="large" style="width:500px" v-model="confirmpass"/>
        <br>
        <br>
        <br>
        <br>
        <a-button type="primary" @click="toStep3">提交</a-button>
        <a-button @click="toStep1">返回</a-button>
    </div>
    
</template>

<script>
export default {
    data() {
        return {
            current: 1,
            password: '',
            confirmpass: ''
        };
    },
    methods:{
        async toStep3(){
            if(this.password!=this.confirmpass){
                this.$message.error('前后两次密码不一致！')
                this.password=''
                this.confirmpass=''
            }
            else{
                const {data:res} = await this.$http.get('http://localhost:8081/user/changepassword',{params:{email:window.sessionStorage.getItem('email'),password:this.password}})
                if(res.code == 200){
                this.$message.success('修改成功！')
                this.$router.push('/Step3')
                }
                else{
                    this.$message.error('修改失败')
                }
            }
            
            
        },
        toStep1(){
            this.$router.push('/Step1')
        },
    }
}
</script>